/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.edu.fatec.ads.classes;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

/**
 *
 * @author Roberta Ferreira
 */
@Entity
@DiscriminatorValue("3")
public class Sala extends Local {

    private Andar andar;

    public Sala() {
        super(3);
    }

    /**
     * @return the andar
     */
    @ManyToOne(fetch=FetchType.LAZY)
    @Fetch(FetchMode.SELECT)
    @JoinColumns(value={@JoinColumn(name = "cd_local_referencia", nullable = false),
                        @JoinColumn(name = "cd_tp_referencia", nullable = false)})
    public Andar getAndar() {
        return andar;
    }

    /**
     * @param andar the andar to set
     */
    public void setAndar(Andar andar) {
        this.andar = andar;
    }

    @Override
    public String toString() {
        return "Sala[codigo=" + this.getCodigo()
                + ", nome=" + this.getNome()
                + ", numero=" + this.getNumero()
                + ", andar=" + this.getAndar().getCodigo() + "]";
    }
}
